package contract.jvm.instructions;

import contract.jvm.Frame;
import contract.jvm.Jvm;
import org.objectweb.asm.tree.VarInsnNode;

public class Iload {

    /**
     * 把局部变量[index]中的int(value)推入操作数栈顶
     */
    public static void iload(Jvm jvm) {
        Frame frame = jvm.jvmStack.lastElement();
        VarInsnNode varInsnNode = (VarInsnNode) jvm.pc.currentInsnNode;
        int index = varInsnNode.var;
        int value = (int) frame.localVariable.get(index);
        frame.operandStack.push(value);
    }

}
